package org.jbfilter.impl;

import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;


/**
 * All thread local stuff comes here.
 */
class _ThreadLocalContainer {

	private Map<String, SimpleDateFormat> patternToSdf = new HashMap<String, SimpleDateFormat>();
	
	public _ThreadLocalContainer() {
		createSimpleDateFormat(_JbFilterDateUtils.DEFAULT_PATTERN);
	}
	
	private void createSimpleDateFormat(String pattern) {
		SimpleDateFormat sdf = new SimpleDateFormat(pattern);
		patternToSdf.put(pattern, sdf);
	}
	public SimpleDateFormat getSimpleDateFormat(String pattern) {
		SimpleDateFormat found = patternToSdf.get(pattern);
		if (found != null) {
			return found;
		} else {
			return new SimpleDateFormat(pattern);
		}
	}
}
